
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'


const qButtonGroup={}
const wButtonGroup={}



const qButtonComponent = require.context("./quick", false, /\.vue$/);
const wButtonComponent = require.context('./window', false, /\.vue$/)

const install = (Vue) => {
    qButtonComponent.keys().forEach((fileName) => {
        let config = qButtonComponent(fileName);
        let componentName = upperFirst(
            camelCase(
                // 获取和目录深度无关的文件名
                fileName
                  .split('/')
                  .pop()
                  .replace(/\.\w+$/, '')
              )
        );

        Vue.component(componentName, config.default || config);
        let active = true
        let button={
            label:componentName,
            name:componentName,
            active:active,
        }
        qButtonGroup[componentName]=button
    });

    wButtonComponent.keys().forEach((fileName) => {
        let config = wButtonComponent(fileName);
        let componentName = upperFirst(
            camelCase(
                // 获取和目录深度无关的文件名
                fileName
                  .split('/')
                  .pop()
                  .replace(/\.\w+$/, '')
              )
        );

        Vue.component(componentName, config.default || config);
        let active = true
        let button={
            label:componentName,
            name:componentName,
            active:active,
        }
        wButtonGroup[componentName]=button
    });
};

export default{
    state:{
        qButtonGroup,
        wButtonGroup
    },
    install
   
}